﻿using System.Windows ;
using System.Windows.Controls ;
using System.ComponentModel.Composition ;
using System.Windows.Threading ;
using System ;

namespace PrismExample.Clock
{
    [Export]
    public partial class View : UserControl
    {
        public View ( )
        {
            this.InitializeComponent( ) ;
            this.Loaded += new RoutedEventHandler( View_Loaded ) ;
        }

        void View_Loaded ( object sender, RoutedEventArgs e )
        {
            var timer = new DispatcherTimer( ) ;
            timer.Interval = TimeSpan.FromSeconds( 1 ) ;
            timer.Tick += new EventHandler( timer_Tick ) ;
            timer.Start( ) ;
        }

        void timer_Tick ( object sender, EventArgs e )
        {
            this.Clock.Text = DateTime.Now.ToShortTimeString( ) ;
        }

    }
}